package dinner.web.money;

import java.util.List;

public class MoneyUtilsDB {

	private static MoneyUtilsDB db = null;

	public static MoneyUtilsDB getDb() {
		if (db == null) {
			db = new MoneyUtilsDB();
		}
		return db;
	}

	Double getCurrentBalance(String name) {
		List<MoneyRecord> db = MoneyIO.getUserStat(name);
		Double res = 0.0;
		for (MoneyRecord d : db) {
			res += d.getLine();
		}
		return res;
	}

	void addBalance(String userName, double summ) {
		MoneyIO.addToUserStat(userName, summ);
	}
}
